package com;

import java.util.Arrays;
import java.util.List;

public class Lambda {
    public static void main(String[] args) {
          Lambda lambda=new Lambda();
//        MathOperation add=(int a,int b) ->a+b;
//        MathOperation subtraction = (a, b) -> a - b;
//        MathOperation multiplication = (int a, int b) -> { return a * b; };
//        MathOperation division = (int a, int b) -> a / b;
//        System.out.println("10+5="+lambda.operate(10,5,add));
//        System.out.println("20-5="+lambda.operate(20,5,subtraction));
//        GreetingService greetService1 = message ->
//                System.out.println("Hello " + message);
//
//        // 用括号
//        GreetingService greetService2 = (message) ->
//                System.out.println("Hello " + message);
//
//        greetService1.sayMessage("Runoob");
//        greetService2.sayMessage("Google");
//        char c=39;
//        System.out.println(c);
        List<Integer> list = Arrays.asList(1,2,3,4,5,6,7);
        Integer sum=1;
        for(Integer n : list) {
            int x = n * n;
            sum = sum + x;
        }
        System.out.println(sum);
        List<Integer> list1 = Arrays.asList(1,2,3,4,5,6,7);
        int sum1 = list.stream().map(x -> x*x).reduce((Integer x,Integer y) -> x * y).get();
        System.out.println(sum1);
        int a=0;
        Integer b=null;
        Long c;
        System.out.println(a+";"+b+";");
        c=11L;
        System.out.println(lambda.aa(c));
    }
    interface MathOperation {
        int operation(int a,int b);
    }
    interface GreetingService {
        void sayMessage(String message);
    }
    public int operate(int a,int b,MathOperation mathOperation){
        return mathOperation.operation(a, b);
    }
    public Long aa(Long l){
        return l;
    }
}
